import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.beans.BeanInfo;
import java.lang.reflect.Array;
import java.sql.SQLOutput;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a1227
 * Date: 2022-07-11
 * Time: 22:21
 */
public class text {
    /**
     * 求数组的平均值
     *
     * @param array
     * @return 数组平均值
     */
    public static double avg(double[] array) {
        double sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
        return sum / array.length;
    }

    /**
     * 求数组的和
     *
     * @param array
     * @return 数组的和
     */
    public static double sum(double[] array) {
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
        }
        return sum;
    }

    /**
     * 使数组的每个元素乘2
     *
     * @param array
     */
    public static void transform(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = array[i] * 2;
        }
    }

    /**
     * 打印数组
     *
     * @param array
     */
    public static void printArray(int[] array) {
        for (int x : array) {
            System.out.print(x + " ");
        }
    }

    /**
     * 冒泡排序
     *
     * @param array
     */
    public static void BubbleSort(int[] array) {
        //趟数
        for (int i = 0; i < array.length - 1; i++) {
            //每趟比较的次数
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                }
            }
        }
    }

    /**
     * 二分查找
     * @param array
     * @param data
     */
    public static void BinarySearch(int[] array,int data){
        int left = 0;
        int right = array.length-1;
        while(left <= right){
            int mid = (left + right) / 2;
            if(array[mid] > data){
                right = mid - 1;
            }else if(array[mid] < data){
                left = mid + 1;
            }else{
                System.out.println("找到了,下标是:"+mid);
                break;
            }
        }
        if(left > right){
            System.out.println("找不到该数字");
        }
    }

    /**
     * 数组拷贝
     * @param array
     * @return
     */
    public static int[] copyOf(int[] array){
        int[] copyarray = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            copyarray[i] = array[i];
        }
        return copyarray;
    }

    /**
     * 数组转换字符串
     * @param array
     * @return
     */
    public static String toString(int[] array){
        String str = "[";
        for (int i = 0; i < array.length; i++) {
            str = str + array[i];
            if(i != array.length-1){
                str = str + ",";
            }
        }
        return str + "]";
    }

    /**
     * 输出闰年
     * @param args
     */
    public static void main1(String[] args) {
        for (int i = 1000; i <= 2000; i++) {
            if((i % 400 == 0)||(i % 4 == 0 && i % 100 != 0)){
                System.out.print(i+" ");
            }
        }
    }

    /**
     * 1-100中有多少个数字9出现
     * @param args
     */
    public static void main0(String[] args) {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if(i / 10 == 9){
                count++;
            }
            if(i % 10 == 9){
                count++;
            }
        }
        System.out.println(count);
    }

    /**
     * 打印素数2
     * @param args
     */
    public static void main2(String[] args) {
        for (int i = 1; i <= 100; i++) {
            if(i == 1){
                System.out.print(1+" ");
            }
            int j = 0;
            for (j = 2; j <= i; j++) {
                if(i % j == 0){
                    break;
                }
            }
            if(i == j){
                System.out.print(i+" ");
            }
        }
    }

    /**
     * 判定素数
     * @param args
     */
    public static void main3(String[] args) {
        Scanner num1 = new Scanner(System.in);
        int num2 = num1.nextInt();
        int i = 0;
        if(num2 == 1){
            System.out.println(num2 + "是素数");
        }
        for(i = 2;i <= num2;i++){
            if(num2 % i == 0){
                break;
            }
        }
        if(num2 != 1) {
            if (num2 == i) {
                System.out.println(num2 + "是素数");
            } else {
                System.out.println(num2 + "不是素数");
            }
        }
    }

    /**
     * 根据输入的年龄, 来打印出当前年龄的人是少年(低于18), 青年(19-28), 中年(29-55), 老年(56以上)
     * @param args
     */
    public static void main(String[] args) {
        Scanner age1 = new Scanner(System.in);
        while(age1.hasNextInt()){
            int age2 = age1.nextInt();
            if(age2 < 18){
                System.out.println("少年");
            }else if(age2 >= 19 && age2 <= 28){
                System.out.println("青年");
            }else if(age2 >= 29 && age2 <= 55){
                System.out.println("中年");
            }else{
                System.out.println("老年");
            }
        }
    }
}



